<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>接口及接口文档</h2>
    省份<input type="text" name="province" value="江西省">城市<input type="text" name="city" value="赣州市">
    <button>测试</button>
    <ul>
        <li></li>
    </ul>
    <script src="./js/axios.js"></script>
    <script>
        const but = document.querySelector('button')
        const province = document.querySelector('input[name=province]')
        const bcityt = document.querySelector('input[ name=city]')
        const list = document.querySelector('ul')
        but.addEventListener('click', function () {
            let pname = province.value
            let cname = bcityt.value

            axios({
                url:'http://ajax-api.itheima.net/api/area',
                method:'GET',
                params:{
                    pname,
                    cname,
                }
            })

            .then(({ data: res }) => {
                let { data } = res
                list.innerHTML = data.map((item) => {

                    return ` <li>${item}</li>`
                }).join ('')
            })
        })
    </script>
</body>

</html>